EXE=card24 card24_v2
CPPFLAGS=-Wall -O0 -g -gdwarf-2 -MMD
USE_FLOAT_VAL=no

VAL_O = value.o

ifeq ($(USE_FLOAT_VAL),yes)
  CPPFLAGS+=-DUSE_FLOAT_VAL
  VAL_O += float_val.o
else
  VAL_O += ana_val.o
endif

all: $(EXE)

$(foreach exe,$(EXE),$(eval $(exe): $(exe:%=%.o) $(VAL_O)))

-include $(VAL_O:.o=.d)

test: card24
	./card24 6 2 3
	./card24 24 2 3 4 5

%: %.o
	g++ $^ -o $@

clean:
	rm -f *.o *.d $(EXE)
	make -C ut clean

help:
	@echo "make: build card24"
	@echo "make clean: clean all"
	@echo "make test: do system test"
	@echo "make help: show this message"

.PHONY: clean test help all
